const express = require("express");
const router = express.Router();
const enterpriseController = require("../../controllers/admin/enterpriseController");

/**
 * @swagger
 * /admin/enterprises:
 *   get:
 *     summary: 获取所有企业信息
 *     responses:
 *       200:
 *         description: 返回所有企业信息
 */
router.get("/", enterpriseController.getAllEnterprises);

/**
 * @swagger
 * /admin/enterprises/{id}:
 *   get:
 *     summary: 获取指定企业信息
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 企业的唯一标识
 *         schema:
 *           type: integer
 *     responses:
 *       200:
 *         description: 返回指定企业的信息
 *       404:
 *         description: 企业未找到
 */
router.get("/:id", enterpriseController.getEnterpriseById);

/**
 * @swagger
 * /admin/enterprises:
 *   post:
 *     summary: 创建企业
 *     description: 创建一个新的企业
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *               industry:
 *                 type: string
 *               credit_code:
 *                 type: string
 *               registered_capital:
 *                 type: number
 *                 format: float
 *               legal_person:
 *                 type: string
 *               address:
 *                 type: string
 *               establish_date:
 *                 type: string
 *                 format: date
 *             required:
 *               - enterpriseName
 *               - industry
 *               - creditCode
 *               - registeredCapital
 *               - legalPerson
 *               - address
 *               - establishDate
 *     responses:
 *       201:
 *         description: 企业创建成功
 *       400:
 *         description: 请求参数不合法
 */

router.post("/", enterpriseController.createEnterprise);

/**
 * @swagger
 * /admin/enterprises/{id}:
 *   delete:
 *     summary: 删除企业
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 企业的唯一标识
 *         schema:
 *           type: integer
 *     responses:
 *       200:
 *         description: 企业删除成功
 *       404:
 *         description: 企业未找到
 */
router.delete("/:id", enterpriseController.deleteEnterprise);

/**
 * @swagger
 * /admin/enterprises/{id}:
 *   put:
 *     summary: 更新企业信息
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 企业的唯一标识
 *         schema:
 *           type: integer
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               enterpriseName:
 *                 type: string
 *               legalPerson:
 *                 type: string
 *               registrationDate:
 *                 type: string
 *                 format: date
 *               capital:
 *                 type: number
 *                 format: float
 *     responses:
 *       200:
 *         description: 企业信息更新成功
 *       404:
 *         description: 企业未找到
 */
router.put("/:id", enterpriseController.updateEnterprise);

module.exports = router;
